package com.oa.entity;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
@Entity(name="Dept")
@Table(name="dept")
public class Dept  implements Serializable{
	private static final long serialVersionUID = -5247017561754419874L;
	@Id
	@GeneratedValue
	private Integer deptno;
	private String dname;
	private String loc;
	
	//加一个集合 创建对象
	@OneToMany(mappedBy="dept",fetch=FetchType.LAZY,cascade={CascadeType.PERSIST,CascadeType.MERGE})
	//private Set<Emp> emps = new HashSet<>();
	
	public Integer getDeptno() {
		return deptno;
	}
	public void setDeptno(Integer deptno) {
		this.deptno = deptno;
	}
	@Column(name="dname",length=14)
	public String getDname() {
		return dname;
	}
	public void setDname(String dname) {
		this.dname = dname;
	}
	@Column
	public String getLoc() {
		return loc;
	}
	public void setLoc(String loc) {
		this.loc = loc;
	}
	@Override
	public String toString() {
		return "Dept [deptno=" + deptno + ", dname=" + dname + ", loc=" + loc
				+ "]";
	}	
/*	public Set<Emp> getEmps() {
		return emps;
	}
	public void setEmps(Set<Emp> emps) {
		this.emps = emps;
	}*/
	
}

